home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 11 - 1995 / 11.04 Apr 95 / TreeAppƒ / Eric's C++ Libraries / Interface Classes / CPPCheckBox.cp < prev    next >
Encoding:
Text File  |  1996-04-04  |  2.2 KB  |  87 lines  |  [TEXT/KAHL]

  1. /********************************************************* DEFINITION
  2.     DATE:    9/23/93
  3.     AUTHOR: Eric R. Rosé
  4.     
  5.     CLASS:  CPPCheckBox
  6.     
  7.     SUPERCLASS: CPPControl
  8.     
  9.         This C++ class manages a checkbox control
  10.     
  11. ********************************************************************/
  12.  
  13. #include <CPPCheckBox.h>
  14.  
  15. extern    Rect    kDefaultRect;
  16. extern    Rect    kEmptyRect;
  17.  
  18. /*-----------------------------------------------------------------*/
  19. /*------------------------ PUBLIC METHODS -------------------------*/
  20. /*-----------------------------------------------------------------*/
  21.  
  22.     CPPCheckBox::CPPCheckBox (CPPWindow *itsWindow, short ResID,
  23.                              Boolean initiallyOn,
  24.                              Boolean canBeTarget,
  25.                              Boolean active, Boolean visible) :
  26.                 CPPControl (itsWindow, ResID, FALSE, canBeTarget, 
  27.                                  active, visible)
  28.     /* load a control resource and initialize with the given data */
  29.     {
  30.         
  31.         if (this->theControl)
  32.           SetValue (initiallyOn);
  33.     }
  34.  
  35. /*-----------------------------------------------------------------*/
  36.  
  37.     CPPCheckBox::CPPCheckBox (CPPWindow *itsWindow, Rect *itsBounds,
  38.                              StringPtr itsText, Boolean initiallyOn,
  39.                               Boolean useWindowFont,
  40.                              Boolean canBeTarget,
  41.                              Boolean active, Boolean visible) :
  42.                 CPPControl (itsWindow, itsBounds, checkBoxProc,
  43.                             itsText, FALSE, useWindowFont,
  44.                             canBeTarget, active, visible)
  45.     {
  46.         if (this->theControl)
  47.           SetValue (initiallyOn);
  48.     }
  49.  
  50. /*-----------------------------------------------------------------*/
  51.  
  52.     CPPCheckBox::~CPPCheckBox (void)
  53.     {
  54.  
  55.     }
  56.  
  57. /*-----------------------------------------------------------------*/
  58.  
  59.     Boolean    CPPCheckBox::Member (char *className)
  60.     {
  61.         if (strcmp(className, CPPCheckBox::ClassName()) == 0)
  62.           return TRUE;
  63.         else
  64.           return CPPControl::Member(className);
  65.     }
  66.  
  67. /*-----------------------------------------------------------------*/
  68.  
  69.     char    *CPPCheckBox::ClassName (void)
  70.     {
  71.         return "CPPCheckBox";
  72.     }
  73.  
  74. /*-----------------------------------------------------------------*/
  75.  
  76.     void    CPPCheckBox::DoOnClick (void)
  77.     /* toggle the value of the checkbox when it is clicked on */
  78.     /* SUBCLASS MAY OVERRIDE */
  79.     {
  80.         if (this->theControl)
  81.           SetValue ((GetValue() + 1) % 2);
  82.           
  83.         // let the superclass run the callback proc
  84.         CPPControl::DoOnClick();
  85.     }
  86.  
  87.